<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>摊位更新</title>
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/jquery.cookie.js"></script>
    <script src="../../js/layer/layer.js"></script>
    <style type="text/css">
        ul li {
            list-style: none;
        }
    </style>
</head>
<body>
<div>
    <ul>
        <li>编号:<input type="text" id="id" name="id"/></li>
        <li>图片:<input type="text" id="name" name="name"/></li>
        <li>描述:<input type="text" id="desc" name="desc"/></li>
        <li><input type="button" value="提交" id="btn"/></li>
    </ul>
</div>
</body>
<script>
    $(function () {
        $("#btn").click(function () {
            submit();
        });
        init();
    });

    function init() {
        var id = getUrlParam("id");
        $.ajax({
            contentType: "json",
            url: baseUrl+"violation-img/getOne.json",
            data: {
                id:id
            },
            success: function (data) {
                if (data.code == "200") {
                    $("#id").val(data.carouselImg.id);
                    $("#name").val(data.carouselImg.name);
                    $("#desc").val(data.carouselImg.desc);
                } else {
                    layer.msg("获取失败!",{icon:5});
                }
            }
        });
    }


    function submit() {
        var clazz = {
            id: $("#id").val(),
            name:$("#name").val(),
            desc:$("#desc").val()
        }
        $.ajax({
            type: "post",
            dataType:"json",
            contentType: "application/json",
            url: baseUrl+"violation-img/update.json",
            data: JSON.stringify(clazz),
            success: function (data) {
                if (data.code == "200") {
                    window.location.href = baseUrl+"/back/violation-img/list.html";
                } else {
                    layer.msg("修改失败!",{icon:5});
                }
            }
        });
    }

</script>
</html>